package com.ruoyi.lab.controller;

import com.github.pagehelper.PageHelper;
import com.ruoyi.lab.domain.JacTestProject;
import com.ruoyi.lab.utils.MyTool;
import com.ruoyi.lab.service.impl.JacTestOutlineServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.lab.domain.JacTestOutline;
import com.ruoyi.lab.service.IJacTestOutlineService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * outline 提供者
 * 
 * @author ruoyi
 * @date 2021-04-06
 */
@RestController
@RequestMapping("outline")
public class JacTestOutlineController extends MyTool
{
	
	@Autowired
	private IJacTestOutlineService jacTestOutlineService;
	
	/**
	 * 查询${tableComment}
	 */
	@GetMapping("get/{projectcode}")
	public Object get(@PathVariable("projectcode") Long projectcode)
	{        startPage();
		     HashMap<String,Object> result=new HashMap<String, Object>();
			 result.put("data", jacTestOutlineService.selectJacTestOutlineById(projectcode));
			 result.put("msg", "success");
			 result.put("code", "0");
			 return result;
	}
	/**
	 * 查询outline列表
	 */
	@GetMapping("list")
	public R list(JacTestOutline jacTestOutline)
	{
        return result(jacTestOutlineService.selectJacTestOutlineList(jacTestOutline));
	}
	@GetMapping("listvendorname")
	public R list(String vendorname)
	{  return result(jacTestOutlineService.selectJacTestOutlineListByVendorname(vendorname));
	}

	/**
	 * 新增保存outline
	 */
	@PostMapping("save")
	public R addSave(@RequestBody JacTestOutline jacTestOutline)
	{		
		return toAjax(jacTestOutlineService.insertJacTestOutline(jacTestOutline));
	}

	/**
	 * 修改保存outline
	 */
	@PostMapping("update")
	public Map<String, String> Save(@RequestBody Map<String,List<JacTestOutline>> jacTestOutline)
	{
		return jacResultMsg(jacTestOutlineService.updateJacTestOutline(jacTestOutline));
	}
	@PostMapping("outlineupdate")
	public R editSave(@RequestBody JacTestOutline jacTestOutline)
	{
		return toAjax(jacTestOutlineService.updateOutline(jacTestOutline));
	}
	@PostMapping("resultupdate")
	public Map<String, String> resultSave(@RequestBody JacTestOutline jacTestOutline)
	{
		return jacResultMsg(jacTestOutlineService.updateMyJacTestOutline(jacTestOutline));
	}
	@GetMapping("submit")
	public Map<String, String> editSubmit(JacTestOutline jacTestOutline)
	{
		return jacResultMsg(jacTestOutlineService.submitJacTestOutline(jacTestOutline));
	}

	@PostMapping("remove")
	public Map<String, String> remove(String projectcodes)
	{		
		return jacResultMsg(jacTestOutlineService.deleteJacTestOutlineByIds(projectcodes));
	}
}
